<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
	.capt{font:normal 40px 맑은고딕}
	.notice{font:normal 12px 맑은고딕; color:gray}
	.adopted{font:bold 12px 맑은고딕; color:darkblue}
	.notAdopted{font:normal 12px 맑은고딕; color:darkred}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("#qnaboard").attr("class", "active");
		
		$("#write").click(function(){
			location.href="${initParam.root}writingPage.ju";
		});
	});
</script>
</head>
<body>

<div  id="right_main" align="center"><!-- right div -->
<table  class="table table-striped table-hover ">
	<%-- <caption class="capt">QnABoard</caption> --%>
	<thead>
		<tr>
			<th align="center" class="adopt">채택여부</th>
			<th align="center" class="title">제목</th>
			<th align="center" class="name">작성자</th>
			<th align="center" class="date">작성일</th>
			<th align="center" class="hit">조회수</th>
		</tr>
	</thead>
	<tbody>
	<c:choose>
		<c:when test="${empty requestScope.listAndPage.list}">
			<tr>
				<td colspan="6" align="center"><b>글이 없습니다.</b></td>
			</tr>
		</c:when>
		<c:otherwise>
			<c:forEach items="${requestScope.listAndPage.list }" var="writing">
			<tr>
				<c:choose>
					<c:when test="${writing.kind==\"공지\"}">
					<td class="notice" align="center">----</td>						
					</c:when>
					<c:otherwise>
						<c:choose>
							<c:when test="${writing.adopted==true}">
							<td class="adopted" align="center">채택완료</td>						
							</c:when>
							<c:otherwise>
							<td class="notAdopted" align="center">채택되지 않음</td>
							</c:otherwise>
						</c:choose>
					</c:otherwise>
				</c:choose>
				<c:choose>
					<c:when test="${writing.kind==\"공지\"}">
					<td><a href="${initParam.root}getQnADetailIncHit.ju?no=${writing.no}"><b>[${writing.kind}]${writing.title }</b></a></td>						
					</c:when>
					<c:otherwise>
					<td><a href="${initParam.root}getQnADetailIncHit.ju?no=${writing.no}">[${writing.kind}]${writing.title }</a></td>
					</c:otherwise>
				</c:choose>
				<td>${writing.memberVO.nickname}</td>
				<td>${writing.date}</td>
				<td>${writing.hit}</td>
			</tr>
			</c:forEach>
		</c:otherwise>
	</c:choose>
	</tbody>
	
	<tfoot>
	<tr>
		<th colspan="5">
		<span style="float: right;">
		<c:if test="${not empty sessionScope.mvo}">
		<!-- 	<input type="button" class="action" id="write" value="글쓰기" > -->
			<input type="image" id="write" src="${initParam.root }img/writeBtn.png" autocomplete="on"  height="25px">
		</c:if>
		</span>
		</th>
		</tr>
	</tfoot>
	
</table>
</div>

<div align="center">
	<c:if test="${requestScope.listAndPage.pagingBean.previousPageGroup}">
		<a href="${initParam.root }getQnAList.ju?page=${requestScope.listAndPage.pagingBean.startPageOfPageGroup - 1 }&title=${requestScope.listAndPage.pagingBean.title}"> ◀ </a>
	</c:if>
	<c:forEach var="p" begin="${requestScope.listAndPage.pagingBean.startPageOfPageGroup }"
	 end="${requestScope.listAndPage.pagingBean.endPageOfPageGroup }">
		<a href="${initParam.root }getQnAList.ju?page=${p}&title=${requestScope.listAndPage.pagingBean.title}">${p }</a>
		<c:if test="${p != requestScope.listAndPage.pagingBean.endPageOfPageGroup}">| 
		</c:if>
	</c:forEach>
	<c:if test="${requestScope.listAndPage.pagingBean.nextPageGroup}">
		<a href="${initParam.root }getQnAList.ju?page=${requestScope.listAndPage.pagingBean.endPageOfPageGroup + 1 }&title=${requestScope.listAndPage.pagingBean.title}"> ▶ </a>
	</c:if>		
</div>
<div align="center">
	<form name="searchForm" action="getQnAList.ju">
	제목 검색  <input type="text" size="50" name="title" id="searchTitle">
	<%-- 	<input type="submit" value="검색"> --%>
<input type="image" id="findBtn" src="${initParam.root }img/searchBtn.png" autocomplete="on"  height="25px">
	</form>
</div>
<br>
</body>
</html>